package com;

import com.alibaba.fastjson.JSONObject;
import lombok.NonNull;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Ricky
 * @date 2020-8-26
 */
@RestController
public class TestController {

    @Async
    @GetMapping("/test")
    public String test(@RequestParam("socketid") @NonNull String socketid, @RequestParam("count") @NonNull int count) throws InterruptedException {
        for (int i = 0; i < count; i++) {
            Thread.sleep(1_000);
            JSONObject data = new JSONObject();
            data.put("xh", i);
            SocketIoServeice.sendInfo(socketid, "cfwc", data);
        }
        return "ok";
    }
}
